1 Research question

This assignment will explore the question:

How have global average temperatures changed overtime?

It will specifically look at data for global average temperatures relative to the average temperature for the period between 1961 and 1990.

2 Data set Introduction

The data used in this assignment is from Ritchie etal., 2020, and can be found at Our World in Data. It contains global average temperatures relative to the average temperature for the time period between 1961 and 1990, for the Entire Globe; the Southern Hemisphere; and the Northern Hemisphere, from 1850 to 2023.

The variables contained in this data set are shown below in Table 2.1 - Variable Names. The variable Entity contains categorical information of either Global, Northern Hemisphere or Southern Hemisphere, meanwhile the variable year contains values from 1850 to 2023. All other variables are described in Table 2.1.

# table of variable names
kable(names(temperature_anomaly),caption = "Variable Names", col.names = 'Names') %>%
  kable_styling()
Table 2.1: Variable Names
Names
Entity
Year
Global average temperature anomaly relative to 1961-1990
Upper bound of the annual temperature anomaly (95% confidence interval)
Lower bound of the annual temperature anomaly (95% confidence interval)

3 Data set Description

The data set contains 5 variables as outlined in Section 2 - Data set Introduction above and 522 observations. The inline code for the previous sentence can be seen below in Figure 3.1.

# show image of inline code
include_graphics("Image/Description_size_of_data.png")
Image of the inline code for data description

Figure 3.1: Image of the inline code for data description

The variable types for the first two observations in the data set are displayed below.

str(head(temperature_anomaly,2))
## tibble [2 × 5] (S3: tbl_df/tbl/data.frame)
##  $ Entity                                                                 : chr [1:2] "Global" "Global"
##  $ Year                                                                   : num [1:2] 1850 1851
##  $ Global average temperature anomaly relative to 1961-1990               : num [1:2] -0.418 -0.233
##  $ Upper bound of the annual temperature anomaly (95% confidence interval): num [1:2] -0.2461 -0.0548
##  $ Lower bound of the annual temperature anomaly (95% confidence interval): num [1:2] -0.589 -0.412

The above information shows that the variable Entity is a character variable meanwhile the remaining four variables are all numeric.

4 Data Summary

# create data set for mean values
measure_mean<-temperature_anomaly %>%
  select(-Year) %>%
  group_by(Entity) %>%
  summarise_all(mean)
# change column names for mean values
colnames(measure_mean)<-c("Entity","Mean Global Average Temperature","Mean Upper Bound Average Temperature", "Mean Lower Bound Average Temperature")
# create data set for median values
measure_median<-temperature_anomaly %>%
  select(-Year) %>%
  group_by(Entity) %>%
  summarise_all(median)
# change column names for mean values
colnames(measure_median)<-c("Entity","Median Global Average Temperature","Median Upper Bound Average Temperature", "Median Lower Bound Average Temperature")
# merge mean and median data and reorder data set for easier comparison
measures <- merge(measure_mean, measure_median) %>%
  select(1,2,5,3,6,4,7)
# create table of mean and median data
kable(measures ,caption = "Mean and Median for Global Average Temperatures including the Upper and Lower Bounds.") %>%
  kable_styling(bootstrap_options = c('bordered',"hover")) %>%
  column_spec(2:3,background = '#cbcbcb') %>%
  column_spec(6:7,background = '#cbcbcb') 
Table 4.1: Mean and Median for Global Average Temperatures including the Upper and Lower Bounds.
Entity Mean Global Average Temperature Median Global Average Temperature Mean Upper Bound Average Temperature Median Upper Bound Average Temperature Mean Lower Bound Average Temperature Median Lower Bound Average Temperature
Global -0.0727916 -0.1755711 0.0250166 -0.0746874 -0.1705997 -0.2613263
Northern hemisphere -0.0206968 -0.1166910 0.0861322 -0.0207820 -0.1275258 -0.2023924
Southern hemisphere -0.1248863 -0.2289955 0.0055675 -0.0867496 -0.2553402 -0.3925451

Table 4.1 shows the mean and median global average temperatures including the upper and lower bound temperature values. The values in this table indicate that the mean temperatures are slightly higher than the median and the Northern Hemisphere is slightly warmer than the Southern Hemisphere.

Table 4.2, below, shows the five figure summary values for the Globe, the Northern Hemisphere and the Southern Hemisphere.

# collect only global Average Temperature and entity
five_figure_summary<-temperature_anomaly %>%
  select(1,3) 
colnames(five_figure_summary)[2]="Global_Average_Temperature"
# create five-figure summary information
table_five_figure <- five_figure_summary %>%
  group_by(Entity) %>%
  summarise(Minimum = min(Global_Average_Temperature), Q1 = quantile(Global_Average_Temperature,0.25),Median = median(Global_Average_Temperature),Q3 = quantile(Global_Average_Temperature,0.75),Maximum = max(Global_Average_Temperature))
# create table of five figure summary
kable(table_five_figure ,caption = "Five Figure Summary of the Global Average Temperatures Relative to the average temperture for the period between 1961 and 1990") %>%
  kable_styling(bootstrap_options = c('bordered',"hover"))
Table 4.2: Five Figure Summary of the Global Average Temperatures Relative to the average temperture for the period between 1961 and 1990
Entity Minimum Q1 Median Q3 Maximum
Global -0.5975614 -0.3413144 -0.1755711 0.0875513 0.9965588
Northern hemisphere -0.7015686 -0.3586852 -0.1166910 0.1194402 1.2757266
Southern hemisphere -0.6252645 -0.3717465 -0.2289955 0.1268128 0.7553061

From table 4.2, the Northern Hemisphere has warmer temperatures except for the following:

To see these values in a graphical version see Figure ??.

5 Visualisations

Below in Figure 5.1 are graphs of the average temperatures with their Upper and Lower values from 1850 until 2023, for the entire Globe; the Northern Hemisphere and the Southern Hemisphere.

# change column names for ease of use
colnames(temperature_anomaly)[3]="Global Average Temperature"
colnames(temperature_anomaly)[4]="Lower Bound"
colnames(temperature_anomaly)[5]="Upper Bound"
# pivot data long for graphing
temp<-temperature_anomaly %>% pivot_longer(cols = 3:5, names_to = "Type", values_to = "number")
# graph a scatter line graph
p<-ggplot(temp,aes(x=Year, y=number, color =Type))+geom_point()+geom_line()+
  # change colours
  scale_colour_manual(values = c("#2375b3","grey","grey"))+
  # show axis line clearly
  theme(axis.line = element_line(linetype = 'solid'))+
  # change y-axis label
  labs(y="Average Temperature Anomaly relative to average temperature between 1961 - 1990")+
  # add 0 line to compare relative values
  geom_hline(yintercept = 0, color = 'grey')+
  # create separate graphs for global, southern, northern hemispheres
  facet_grid(Entity~.)
# add hover over for further information
p<-ggplotly(p) %>%
  # change position of legend
  layout(legend=list(orientation='h'))
p

Figure 5.1: Average Temperature Anomaly relative to average temperature between 1961 -1990’ from 1850 to 2023

Figure 5.1 shows the following key observations in relation to the analysis question, How have global average temperatures changed overtime?:

6 Conclusion

From the analysis completed in this task the following conclusions can be made when answering the question: How have global average temperatures changed overtime?. Table 4.1 indicates that the Northern Hemisphere has slightly warmer global average temperatures when compared to the Southern Hemisphere. This was further supported by the data in Figure 5.1, where it was seen the Northern Hemisphere had an increase of 1.6 degrees while the Southern Hemisphere had an increase of 1.1 degrees over the time period from 1850 to 2023. Figure 5.1, also showed that the average global temperatures have increased by 1.2 degrees in the time period from 1850 to 2023.

In summary, the global average temperatures are increasing with this increase worse in the Northern Hemisphere.

7 References

Ritchie, H., Roser, M., & Rosado, P. (2020, May 11). CO₂ and greenhouse gas emissions. Our World in Data. https://ourworldindata.org/co2-and-greenhouse-gas-emissions